#include <linux/init.h>
#include <linux/module.h>

#include "../include/share.h"

MODULE_LICENSE("Dual BSD/GPL");

struct kmsg_node;
typedef int (kmsg_end_msg_t) (struct kmsg_node *, int, int);
typedef struct kmsg_node {
	atomic_t ref_cnt;
	struct list_head list;
	kmsg_msg_t *msg;
	kmsg_end_msg_t *end_msg;
	void *priv_data;
}kmsg_node_t;

extern kmsg_node_t *alloc_kmsg_node(void *, kmsg_end_msg_t *,  void *);
extern void kmsg_send(kmsg_node_t *);
extern void kmsg_node_put(kmsg_node_t *);

int test_end(kmsg_node_t *node, int end_cnt, int error)
{
	kmsg_node_put(node);
	printk(KERN_ERR "yangp01:: test end\n");
	return 0;
}

void test_kmsg(void)
{
	kmsg_msg_t msg[1];
	char str[] = "abc";
	kmsg_node_t *node = alloc_kmsg_node(msg, test_end, NULL);
	msg->type = 1;
	strcpy(msg->info, str);
	kmsg_send(node);
}

static __init int test_init(void)
{
	printk(KERN_ERR "test init \n");
	return 0;
}

static __exit void test_exit(void)
{
	printk(KERN_ERR "test exit \n");
}

module_init(test_init);
module_exit(test_exit);

